package com.example.test.责任链1;


public class ZeRenChain {

    AddMethodService head;

    AddMethodService body;

    public void addNext(AddMethodService tail) {
        if (null == head) {
            head = tail;
            body = tail;
            return;
        }
        body.setNext(tail);
        body = tail;
    }

    public void start(int num) {
        if (null != this.head) {
            int i = this.head.addNum(num);
            AddMethodService next = this.head.getNext();
            if (next != null) {
                next.execute(i);
            }
        }
    }

}
